<% 	var attachment_name;
	if(_.isEmpty(attachment.attributes.link) && !_.isEmpty(attachment.attributes.name)){
		attachment_name = encodeURI(attachment.attributes.name); 
	}
	if(_.isEmpty(attachment.attributes.link) && !_.isEmpty(attachment.attributes.name)){
	if(attachment.attributes.name.toLowerCase().match(/\.(jpg|jpeg|png|gif|webp|bmp|ico)$/)){ 
		var picture_path = attachment.showImage('CardAttachment', attachment.attributes.id, 'original' );
		var picture_thumb = attachment.showImage('CardAttachment', attachment.attributes.id, 'large_thumb' );
	%>
	<a data-fancybox="images" data-caption="<%= decodeURI(attachment_name) %>" href="<%= picture_path %>" class="pull-left navbar-btn img-thumbnail js-card-attachment-<%- card_id %>">
		<% if(attachment.attributes.name.toLowerCase().match(/\.(jpg|jpeg|png|gif|bmp|ico)$/)){ %>
			<img src="<%= picture_thumb %>">
		<% } else if(attachment.attributes.name.toLowerCase().match(/\.(webp)$/)){ %>
			<img src="<%= picture_path %>">
		<% } %>
	</a>
	<% } else if (attachment.attributes.name.toLowerCase().match(/\.(pdf)$/) && !_.isUndefined(attachment.attributes.doc_image_path) && !_.isEmpty(attachment.attributes.doc_image_path) && attachment.attributes.doc_image_path !== null) { 
		var document_path = attachment.documentLink('Card', attachment.attributes); %>
		<a data-fancybox="images" data-caption="<%= decodeURI(attachment_name) %>" href="<%= document_path %>" class="pull-left navbar-btn img-thumbnail js-card-attachment-<%- card_id %>">
			<img src="/img/<%= attachment.attributes.doc_image_path %>">
		</a>
	<% } else {
		var document_path = attachment.documentLink('Card', attachment.attributes);
		var extension = attachment.attributes.name.split('.');
	%>
		<a data-fancybox="images" data-caption="<%= decodeURI(attachment_name) %>" href="<%= document_path %>" class="pull-left navbar-btn img-thumbnail js-card-attachment-<%- card_id %>"><p class="thumb-img"><%- extension[extension.length - 1].toUpperCase() %></p></a>
	<% } %>
<% } else if(!_.isEmpty(attachment.attributes.link)){ %>
	<%   
		if (navigator.userAgent.toLowerCase().indexOf('uiwebview') > -1) { 
	%>
		<a target="_self" href="<%= attachment.attributes.link %>" title="<%- attachment.attributes.link %>" class="pull-left navbar-btn img-thumbnail">
	<% }else{ %>
		<a target="_blank" href="<%= attachment.attributes.link %>" title="<%- attachment.attributes.link %>" class="pull-left navbar-btn img-thumbnail">
	<% } %>
		<p class="thumb-img">
		<% if (attachment.attributes.link.indexOf("dropbox.com") > -1) {%>
			<i class="icon-dropbox"></i>
		<% } else if(attachment.attributes.link.indexOf("docs.google.com") > -1){ %>
			<i class="icon-cloud"></i>
		<% } else if(attachment.attributes.link.indexOf("github.com") > -1){ %>
			<i class="icon-github"></i>
		<% } else if(!_.isEmpty(attachment.attributes.name) && !_.isEmpty(attachment.attributes.link)) {  var extension = attachment.attributes.name.split('.'); %><% if(!_.isUndefined(extension) && extension.length > 1) { %><% if(attachment.attributes.name.toLowerCase().match(/\.(jpg|jpeg|png|webp|gif)$/)){ %><%- extension[extension.length - 1].toUpperCase() %><% } else { %>LINK<% } } %><% }%>
		</p>
	</a>
<% } %>
<div class="clearfix">
<% if(_.isEmpty(attachment.attributes.link) && !_.isEmpty(attachment.attributes.name)){ %>
	<% 
		if (navigator.userAgent.toLowerCase().indexOf('uiwebview') > -1) { 
	%>
		<a target="_self" href="<%= attachment.downloadLink('download', attachment.attributes.id) %>" title="<%- decodeURI(attachment_name) %>"><span class="show htruncate col-xs-11 nav"><%- decodeURI(attachment_name) %></span>
	<% } else { %>
		<a target="_blank" href="<%= attachment.downloadLink('download', attachment.attributes.id) %>" title="<%- decodeURI(attachment_name) %>"><span class="show htruncate col-xs-11 nav"><%- decodeURI(attachment_name) %></span>
	<% } %>
		<span class="show btn-block col-xs-12"><%- i18next.t('Added') %> <small class="text-muted">
		<% setInterval(function() {%>
			<% parse_date(attachment.attributes.created, authuser, 'js-timeago-card-attachment1-'+attachment.attributes.id); %>
		<% }, 10000); %>
		<span class="js-timeago-card-attachment1-<%- attachment.attributes.id %>"><%= parse_date(attachment.attributes.created, authuser, 'js-timeago-card-attachment1-'+attachment.attributes.id, true) %></span>
		</small></span></a>
<% } else if(!_.isEmpty(attachment.attributes.link)){ %>
	<% 
		if (navigator.userAgent.toLowerCase().indexOf('uiwebview') > -1) { 
	%>
		<a target="_self" href="<%= attachment.attributes.link %>" title="<%- attachment.attributes.link %>">
	<% } else { %>
		<a target="_blank" href="<%= attachment.attributes.link %>" title="<%- attachment.attributes.link %>">
	<% } %>
			<span class="show htruncate col-xs-11 nav"><%- attachment.attributes.link %></span><span class="show btn-block col-xs-12"><%- i18next.t('Added') %> <small class="text-muted">
			<% setInterval(function() {%>
				<% parse_date(attachment.attributes.created, authuser, 'js-timeago-card-attachment2-'+attachment.attributes.id); %>
			<% }, 10000); %>
		<span class="js-timeago-card-attachment2-<%- attachment.attributes.id %>"><%= parse_date(attachment.attributes.created, authuser, 'js-timeago-card-attachment2-'+attachment.attributes.id, true) %></span>
			</small></span>
		</a>
<% } %>
<%if(!_.isUndefined(authuser.user)) {%>
	<div class="btn-toolbar navbar-btn">
		<div class="btn-group btn-group-xs navbar-btn no-print">
			<% if(!_.isUndefined(authuser.user) && (authuser.user.role_id == 1 || !_.isEmpty(attachment.board.acl_links.where({slug: "download_attachment_card", board_user_role_id: parseInt(attachment.board.board_user_role_id)})))) {
			%>
			<div class="btn btn-primary">	
			<%
			if(_.isEmpty(attachment.attributes.link)) {%> 
			<% 
				var download_link = attachment.downloadLink('download', attachment.attributes.id);
			%>
			<a target="_blank" href="<%= download_link %>" title="<%- i18next.t('Download') %>">
				<i class="icon-arrow-down cur icon-light"></i></a>
			<% } else {%>
				<% var link_title = 'Open in New Tab'; %>
				   <% if (attachment.attributes.link.indexOf("dropbox.com") > -1) {%>
					<% link_title = 'Open in Dropbox'; %>
				<% } else if(attachment.attributes.link.indexOf("docs.google.com") > -1){ %>
					<% link_title = 'Open in Google Drive'; %>
				<% } else if(attachment.attributes.link.indexOf("github.com") > -1){ %>
					<% link_title = 'Open in Github'; %>
				<% } %>
				<a target="_blank" href="<%= attachment.attributes.link %>" title="<%- link_title %>">
				<i class="icon-external-link cur icon-light"></i></a>
			<% } %>
			</div>
			<% } %>
				<% if(!_.isUndefined(authuser.user) && (authuser.user.role_id == 1 || !_.isEmpty(attachment.board.acl_links.where({slug: "remove_card_attachment", board_user_role_id: parseInt(attachment.board.board_user_role_id)})))) { %> 
					<div class="dropdown pull-left">
						<a href="#" title="<%- i18next.t('Delete') %>" class="btn btn-default btn-xs js-show-confirm-delete-attachment dropdown-toggle" data-toggle="dropdown">
							<i class="icon-remove cur"></i>
						</a>
						<ul class="dropdown-menu arrow list-unstyled">
							<li class="js-dropdown-popup js-attachment-confirm-respons-<%- attachment.id %>"></li>
						</ul>
					</div>
				<% } %>
				<% if(_.isEmpty(attachment.attributes.link) && !_.isEmpty(attachment.attributes.name) && (attachment.attributes.name.toLowerCase().match(/\.(jpg|jpeg|png|gif|webp|bmp|ico)$/) || (attachment.attributes.name.toLowerCase().match(/\.(pdf)$/) && !_.isUndefined(attachment.attributes.doc_image_path) && !_.isEmpty(attachment.attributes.doc_image_path) && attachment.attributes.doc_image_path !== null))) { %> 
				<div class="btn btn-primary">
					<% if (this.card.attributes.cover_image_id === attachment.id) {%>
						<a href="javascript:void(0);" title="<%- i18next.t('Remove cover') %>" class="js-attachment-remove-cover js-cover-img-option" data-id="<%- attachment.id %>">
							<i class="icon-folder-close cur icon-light"></i> Remove cover
						</a>
					<% } else { %>
						<a href="javascript:void(0);" title="<%- i18next.t('Make cover') %>" class="js-attachment-make-cover js-cover-img-option" data-id="<%- attachment.id %>">
							<i class="icon-folder-close cur icon-light"></i> Make cover
						</a>
					<% } %>
				</div>
				<% } %>
		</div>
	</div>
<% } %>
</div>